package com.yuan.web.servlet;

import com.yuan.pojo.User;
import com.yuan.service.UserService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

@WebServlet("/userlist")
public class ServletShowAll extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        UserService userService = new UserService();
        try {
            List<User> userlist = userService.showUser();
            request.setAttribute("listUser",userlist);
            request.getRequestDispatcher("list.jsp").forward(request, response);
        } catch (Exception throwables) {
            throwables.printStackTrace();
        }
    }
}
